﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EasyGrocer.BusinessLayer.ServiceRepository;
using EasyGrocer.DataLayer;

namespace EasyGrocer.UI
{
    public partial class ProductList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            IProductServiceRep productRep = BusinessServiceFactory.CreateProductService();
            HttpContext context = new HttpContextContainer().GetCurrentHttpContext();
            if(context.Request.QueryString["id"]!=null)
            {
                Guid categoryId = new Guid(context.Request.QueryString["id"]);
                IEnumerable<Product> products = productRep.GetByCategoryId(categoryId);
                ProductView.DataSource = products;
                ProductView.DataBind();
            }

        }
    }
}
